#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import os
import requests
import glovar
URL = "https://danjuanapp.com/djapi/index_eva/dj"

headers = {
        'Host':'danjuanapp.com',
        'User-Agent':'Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.92 Mobile Safari/537.36',
}

def getFundData():
    data = requests.get(URL,headers = headers).content
    return data

def save(path,htmlStr):
    f = open(path, 'wb+')
    f.write(htmlStr)
    f.close

def work():
    fundData = getFundData()
    savePath = os.path.join(glovar.store_path,"fund.json")
    save(savePath,fundData)
    print(fundData)

if __name__ == "__main__":
    work()